package com.ljyanimo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ljyanimo.entity.SysUserRole;
import com.ljyanimo.mapper.SysUserRoleMapper;
import com.ljyanimo.service.ISysUserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author
 * @since 2020-10-16
 */
@Service
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements ISysUserRoleService {


    @Override
    public List<Integer> selectUserRoleByUserId(Integer userId) {
        return baseMapper.selectList(
                new QueryWrapper<SysUserRole>().select("role_id")
                        .eq("user_id", userId))
                .stream().map(SysUserRole::getRoleId).collect(Collectors.toList());
    }
}
